import 'dart:core';

import 'package:sui_shou_pai/record/record_entity/photo_record_entity.dart';

class CommentedPhotoRecords {
  PhotoRecordEntity photoRecordEntity;
  String comment;
  String commentTime;

  CommentedPhotoRecords(
    this.photoRecordEntity,
    this.comment,
    this.commentTime,
  );

  static CommentedPhotoRecords fromMap(Map<String, dynamic> map) {
    String comment = map['comment'];
    if (comment.length > 9) {
      comment = comment.substring(0, 7) + "...";
    }
    String content = map['content'].toString();

    if (content.length > 10) {
      content = content.substring(0, 8) + "...";
    }
    return CommentedPhotoRecords(
        PhotoRecordEntity(
            map['id'].toString(),
            map['createTime'].toString().substring(0, 10),
            map['employee_id'].toString(),
            map['publisherName'].toString(),
            map['responsibleName'].toString(),
            map['location'].toString(),
            map['type'].toString(),
            map['title'].toString(),
            content,
            map['image'].toString(),
            map['status'].toString(),
            map['responsible_id'].toString()),
        comment,
        map['commentTime']);
  }
}
